package com.yanqu.road.server.cmd.estatewar;

import com.yanqu.road.pb.estatewar.EstateWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.EstateWarModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_ESTATE_WAR_CHANGE_SKIN, desc = "府邸变更皮肤")
public class EstateWarChangeSkinCmd extends AbstractCommand {

	private int estateSkinId;

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		EstateWarProto.EstateChangeSkinReqMsg reqMsg = EstateWarProto.EstateChangeSkinReqMsg.parseFrom(packet.getBytes());
		estateSkinId = reqMsg.getSkinId();
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		ret = player.getModule(EstateWarModule.class).changeSkin(estateSkinId);
	}

	@Override
	public void sendData(GamePlayer player) {
		EstateWarProto.EstateChangeSkinRespMsg.Builder respMsg = EstateWarProto.EstateChangeSkinRespMsg.newBuilder();
		respMsg.setRet(ret);
		player.sendPacket(Protocol.U_ESTATE_WAR_CHANGE_SKIN, respMsg);
	}

}
